<?php

namespace App\Http\Resources\Admin;

use Illuminate\Http\Resources\Json\Resource;

class Product extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'info' => $this->info,
            'price' => $this->price,
            'unit' => $this->unit,
            'status' => $this->status,
            'cover_image' => $this->cover_image,
            'pic_group' => $this->pic_group,
            'address' => $this->address,
            'cate_id' => $this->cate_id,
            'rcmd' => $this->rcmd,
            'logistics_mode' => $this->logistics_mode,
            'created_at' => $this->created_at->format('Y-m-d H:i:s'),
            'shop' => $this->whenLoaded('shop'),
        ];
    }
}
